<template>
  <div>
    <el-card class="oneCard" @click.native="jump">
      <div>
        <div>
          <el-link :type="type" :underline="false">{{ total }}</el-link>
          <h2>{{ name }}</h2>
        </div>
        <div><svg-icon :icon-class="icon" /></div>
      </div>
    </el-card>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
import { countStats } from '@neu/dcam-ui/api/workOrder'
export default {
  name: 'WorkorderStats',
  props: {
    status: {
      required: false,
      type: String,
      default: 'todo'
    },
    icon: {
      required: false,
      type: String,
      default: 'todo'
    },
    name: {
      required: false,
      type: String,
      default: '待办工单'
    }
  },
  data() {
    return {
      type: 'warning',
      total: '--'
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  mounted() {
    this.getTotal()
  },
  methods: {
    // 获取数量
    getTotal() {
      countStats(this.status).then(res => {
        this.total = res.data ? res.data : 0
      })
      this.total = 0
    },
    jump() {
      this.$router.push({ name: this.status === 'todo' ? 'dcam_todoworkorder' : (this.status === 'me' ? 'dcam_myworkorder' : 'dcam_doneworkorder') })
    }
  }
}
</script>
